package com.itmuch.content_center.controller.share;

import com.itmuch.content_center.domain.dto.share.ShareDTO;
import com.itmuch.content_center.service.share.ShareService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/shares")
public class ShareController {

    private final ShareService shareService;

    private final DiscoveryClient discoveryClient;

    @RequestMapping("/{id}")
    public ShareDTO findById(@PathVariable Integer id){return shareService.findById(id);}


    @RequestMapping("/test2")
    public List<ServiceInstance> getInstance(){
        return this.discoveryClient.getInstances("user-center");
    }

}
